﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyVoteMVC.Domain;
using System.Data.Entity.ModelConfiguration;

namespace MyVoteMVC.Data.Mapping
{
    public class VT_UsersMap : EntityTypeConfiguration<VT_Users>
    {
        public VT_UsersMap()
        {
            // Primary Key
            this.HasKey(t => t.User_ID);

            // Properties
            this.Property(t => t.User_ID)
                .IsRequired()
                .HasMaxLength(36);

            this.Property(t => t.User_Name)
                .HasMaxLength(100);

            this.Property(t => t.User_RealName)
                .HasMaxLength(100);

            this.Property(t => t.User_Email)
                .HasMaxLength(100);

            this.Property(t => t.User_Password)
                .HasMaxLength(50);

            this.Property(t => t.Created_By)
                .HasMaxLength(100);

            this.Property(t => t.Created_Action)
                .HasMaxLength(200);

            this.Property(t => t.Last_Update_By)
                .HasMaxLength(100);

            this.Property(t => t.Last_Update_Action)
                .HasMaxLength(200);

            this.Ignore(t => t.User_IfAdmin);
            this.Ignore(t => t.User_IfLeader);

            // Table & Column Mappings
            this.ToTable("VT_Users");
            this.Property(t => t.User_ID).HasColumnName("User_ID");
            this.Property(t => t.User_Name).HasColumnName("User_Name");
            this.Property(t => t.User_RealName).HasColumnName("User_RealName");
            this.Property(t => t.User_Email).HasColumnName("User_Email");
            this.Property(t => t.User_Password).HasColumnName("User_Password");

            this.Property(t => t.User_IfAdminValue).HasColumnName("User_IfAdmin");
            this.Property(t => t.User_IfLeaderValue).HasColumnName("User_IfLeader");

            this.Property(t => t.Created_By).HasColumnName("Created_By");
            this.Property(t => t.Created_Date).HasColumnName("Created_Date");
            this.Property(t => t.Created_Action).HasColumnName("Created_Action");
            this.Property(t => t.Last_Update_By).HasColumnName("Last_Update_By");
            this.Property(t => t.Last_Update_Date).HasColumnName("Last_Update_Date");
            this.Property(t => t.Last_Update_Action).HasColumnName("Last_Update_Action");
        }
    }
}
